<?php

/**
 * @Author: kendy
 * @Date:   2020-01-08 09:00:16
 * @Last Modified by:   jiayanting
 * @Last Modified time: 2020-03-30 11:11:17
 */
namespace app\admin\model;
use think\Model;
use think\Db;

class Orders extends Model
{
	public function getRefundOrderInfo($where){
      
	} 

	public function getOrderInfo($object_id,$order_sn,$type){
		$result = []; 
       //1导游2景点3跟团4酒店 
       if($type==2){$table=Db::name('tour_order');}
       if($type==3){$table=Db::name('gtour_order');}
       if($type==4){$table=Db::name('hotel_order');} 
       $result = $table
       ->alias("o")
       ->field("o.order_sn,o.pay_type,o.order_price,o.create_time,o.order_status,o.linkman,o.tel,or.back_money,refund_time,or.refund_status,or.create_time as app_time,or.refund_reson")
       ->where(['o.order_sn'=>$order_sn])
       ->join("order_refund or",'or.order_sn=o.order_sn','left')  
       ->find();  
       if(!empty($result)){
            if($result['refund_time'])
            $result['refund_time'] = date('Y-m-d H:i:s',$result['refund_time']);
       	$result['create_time'] = date('Y-m-d H:i:s',$result['create_time']);
       	$result['app_time'] = date('Y-m-d H:i:s',$result['app_time']);
       	if($type==2){
       		$result['title'] = "景点";
           $result['name'] = Db::name('tours')->where('tour_id',$object_id)->value("tour_name"); 
       	} 
       	if($type==3){
       	   $result['title'] = "跟团";
           $result['name'] = Db::name('group_tour')->where('id',$object_id)->value("gtour_title"); 
       	} 
       	if($type==4){
       	   $result['title'] = "酒店";
           $result['name'] = Db::name('hotel')->where('hotel_id',$object_id)->value("hotel_name"); 
       	}  
       	$result['pay_type'] = lvPayType($result['pay_type']);
            $result['order_status'] = lvOrderStatus($result['order_status']);
      //0申请中1已同意2已拒绝
       	if($result['refund_status']==0){$result['refund_status']="申请中";}
       	if($result['refund_status']==1){$result['refund_status']="已同意";}
       	if($result['refund_status']==2){$result['refund_status']="已拒绝";}
       }
       return $result;
	}

}